package org.diancai.diancai.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ResourceConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射规则：前端访问 /images/** 路径时，实际访问本地 C:\Users\86136\Pictures\food\ 目录
        String imagePath = "file:C:/Users/86136/Pictures/food/";  // 本地图片目录的绝对路径（注意斜杠方向）
        registry.addResourceHandler("/images/**")  // 前端访问路径前缀
                .addResourceLocations(imagePath);  // 映射到本地图片目录
    }
}